<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class OrderGoods extends Model
{
    protected $guarded  = [];
    protected $appends = ['shipping_checked', 'shipping_disabled'];

    public function getShippingCheckedAttribute()
    {
        $checked = false;
        $status = $this->attributes['status'];
        if ($status == 0) {
            $checked = true;
        }
        return $checked;
    }
    public function getShippingDisabledAttribute()
    {
        $disabled = false;
        $status = $this->attributes['status'];
        if ($status !== 0) {
            $disabled = true;
        }
        return $disabled;
    }
    public function getGoodsThumbAttribute($value)
    {
        return asset('storage/'.$value);
    }

    public function order()
    {
        return $this->belongsTo('App\Order');
    }

    public function goods()
    {
        return $this->belongsTo('App\Goods');
    }
}
